<!DOCTYPE html>
<html>
<head>
    <title>gimi1.5-批量注册域名</title>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.6.0/jquery.min.js"></script>
</head>
<body>
<input type="text" id="domains" placeholder="请输入域名，用逗号分隔">
<button onclick="checkPrices()">查询价格</button>
<div id="result"></div>

<script>
    const API_URL = 'https://your-api-endpoint'; // 替换为你的接口地址

    function checkPrices() {
        const domains = $('#domains').val().split(',');
        $('#result').empty();

        $.ajax({
            url: API_URL,
            type: 'POST',
            data: { domains: domains },
            success: function(response) {
                if (response.success) {
                    for (const domain in response.data) {
                        const price = response.data[domain];
                        $('#result').append(`<p>${domain}: ${price}元 <button onclick="registerDomain('${domain}')">立即注册</button></p>`);
                    }
                } else {
                    $('#result').append('<p>查询失败：' + response.message + '</p>');
                }
            },
            error: function() {
                $('#result').append('<p>查询失败：请检查网络连接或接口地址。</p>');
            }
        });
    }

    function registerDomain(domain) {
        $.ajax({
            url: API_URL + '/register',
            type: 'POST',
            data: { domain: domain },
            success: function(response) {
                if (response.success) {
                    alert('注册成功！');
                } else {
                    alert('注册失败：' + response.message);
                }
            },
            error: function() {
                alert('注册失败：请检查网络连接或接口地址。');
            }
        });
    }
</script>
</body>
</html>